#!/bin/bash

dependent_project=$1 #第一个参数为是否为从节点，默认为1 否 必须参数
# nodejs_home=$2 #node的目录
# export PATH=\$PATH:${nodejs_home}/bin
echo "设置私服 config set registry http://qdhz.0tool.com:18081/repository/npm-group/"
npm config set registry http://qdhz.0tool.com:18081/repository/npm-group/
npm cache clean --force
dependent_project_array=(${dependent_project//,/ })
for project_item in ${dependent_project_array[@]}
do
{
  echo "删除依赖$project_item 并重新安装依赖"
  npm uninstall $project_item
  npm install $project_item
} #& 追加&的场合，异步
done
wait
echo "查看安装是否有新追加的包"
npm install
echo "打包构建"
npm run build:prod
npm publish --registry=http://qdhz.0tool.com:18081/repository/npm-hosted/